<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>

        <ui:composition template="./template.xhtml">

            <ui:define name="title">
                Add Device
            </ui:define>

            <ui:define name="content">
                <h:form>
                    <table align="center" width="500px">
                        <tr>
                            <td colspan="2" align="center"><h3>Add New Device</h3></td><td></td>
                        </tr>
                        <tr>
                            <td colspan="3"><p:messages id="messages" showDetail="true" autoUpdate="true"  globalOnly="true"/></td>
                        </tr>
                        <tr>
                            <td>Lab Name</td>
                            <td>
                                <h:selectOneMenu id="labname" value="#{addDeviceBean.labid}" required="true" requiredMessage="Lab empty !">
                                    <f:selectItems value="#{addDeviceBean.labs}" var="l" itemLabel="#{l.labname}" itemValue="#{l.labID}" />
                                </h:selectOneMenu>
                            </td>
                            <td><p:message for="labname" /></td>
                        </tr>
                        <tr>
                            <td>Device Name</td>
                            <td><h:inputText value="#{addDeviceBean.devicename}" id="name" required="true" requiredMessage="Device Name invalid!" /></td>
                            <td> <p:message for="name"/></td>
                        </tr>
                        <tr>
                            <td>Description</td>
                            <td><h:inputTextarea value="#{addDeviceBean.description}" id="desc" required="true" requiredMessage="Description invalid !" /></td>
                            <td><p:message for="desc" /></td>
                        </tr>
                        <tr>
                            <td></td><td><h:commandButton value="Add Device" action="#{addDeviceBean.resultAdd}" /></td><td></td>
                        </tr>
                    </table>
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
